﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Entity;
using System.Runtime.Remoting.Messaging;

namespace WuZu.DAL
{
    public partial class DBContentFactory
    {
        /// <summary>
        /// 创建EF上下文对象，已存在就直接取，不存在就保存，保证线程的唯一性
        /// </summary>
        /// <returns></returns>
        public static DbContext Create()
        {
            DbContext dbContent = CallContext.GetData("DbContext") as DbContext;
            if(dbContent==null)
            {
                dbContent = new WuZu.Model.wuzuexamEntities();
                CallContext.SetData("DbContext", dbContent);
            }
            return dbContent;
        }
    }
}
